//
//  Request.h
//  PigMarket
//
//  Created by Felix on 2019/4/11.
//  Copyright © 2019 felix.pigmarket.oc. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "YYModel.h"

#define kHTTPMethodGET @"GET"
#define kHTTPMethodPOST @"POST"

NS_ASSUME_NONNULL_BEGIN

/**
 认证方式
 
 - OAuthTypeNone: 无
 - OAuthTypeClient: 客户端认证
 - OAuthTypeUser: 用户认证
 */
typedef NS_ENUM(NSInteger, OAuthType) {
    OAuthTypeNone = 1,
    OAuthTypeMember = 2
};

@interface Request : NSObject

/**
 请求地址（全地址）
 */
@property(nonatomic,strong) NSString *URLString;

/**
 请求方式
 */
@property(nonatomic, strong) NSString *method;

/**
 认证类型
 */
@property(nonatomic, assign) enum OAuthType oauthType;

/**
 请求头
 */
@property(nonatomic,strong) NSDictionary<NSString *,NSString *> *headers;

/**
 请求参数
 */
@property(nonatomic,strong) id param;

/**
 响应数据类型（指响应信息的data数据，如果data为集合，那这个类型为集合元素的数据类型）
 */
@property(nonatomic,assign,nullable) Class responseType;

- (instancetype)initWithURLString:(NSString *) URLString
                           method:(NSString *) method
                        oauthType:(enum OAuthType) oauthType;

- (instancetype)initWithURLString:(NSString *) URLString
                           method:(NSString *) method
                        oauthType:(enum OAuthType) oauthType
                            param:(nullable id) param;

- (instancetype)initWithURLString:(NSString *) URLString
                           method:(NSString *) method
                        oauthType:(enum OAuthType) oauthType
                           header:(nullable NSDictionary<NSString *,NSString *> *) headers
                            param:(nullable id) param;


+ (instancetype)requestWithURLString:(NSString *) URLString
                              method:(NSString *) method
                           oauthType:(enum OAuthType) oauthType;

+ (instancetype)requestWithURLString:(NSString *) URLString
                              method:(NSString *) method
                           oauthType:(enum OAuthType) oauthType
                               param:(nullable id) param;

+ (instancetype)requestWithURLString:(NSString *) URLString
                              method:(NSString *) method
                           oauthType:(enum OAuthType) oauthType
                              header:(nullable NSDictionary<NSString *,NSString *> *) headers
                               param:(nullable id) param;

@end

NS_ASSUME_NONNULL_END
